package com.itheima.chapter09.io.properties;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

//与IO流结合
public class Demo3 {
    public static void main(String[] args) throws IOException {
        //把集合中的数据保存到文件中
        //method1();
        //把文件中的数据加载到集合
        method2();
    }

    private static void method2() throws IOException {
        Properties prop =new Properties();
        FileReader fr =new FileReader("MyIdeaTest\\prop.propertise");
        prop.load(fr);
        fr.close();
        System.out.println(prop);
    }

    private static void method1() throws IOException {
        Properties prop =new Properties();
        prop.put("zhangsan","23");
        prop.put("lisi","26");
        prop.put("wangwu","34");
        prop.put("sunlou","56");
        prop.put("zhouyi","17");
        FileWriter fw =new FileWriter("MyIdeaTest\\prop.propertise");
        prop.store(fw,"woshizhushi");
        fw.close();
    }
}
